* importing dataset
import delimited "~/brewery_panel_20250307.csv", clear

* encoding state variable 
* encode state, gen(state_num)

* defining geographic and temporal units
xtset zipcode year
destring perbach, replace force

* baseline model:: brewery
ppmlhdfe brewery lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, absorb(zipcode  year) vce(cluster zipcode)

outreg2 using "brewery_ppml_main_0307.tex", alpha(0.001, 0.01, 0.05) replace

* baseline model:: style
ppmlhdfe style lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, absorb(zipcode state year) vce(cluster zipcode)

outreg2 using "brewery_ppml_main_0307.tex", alpha(0.001, 0.01, 0.05) append

* baseline model:: beeer
ppmlhdfe beer lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, absorb(zipcode state year) vce(cluster zipcode)

outreg2 using "brewery_ppml_main_0307.tex", alpha(0.001, 0.01, 0.05) append


****APPENDIX
***xtnbreg
xtnbreg brewery lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, fe

outreg2 using "brewery_alternative_xtnbreg_0307.tex", alpha(0.001, 0.01, 0.05) replace

xtnbreg style lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, fe

outreg2 using "brewery_alternative_xtnbreg_0307.tex", alpha(0.001, 0.01, 0.05) append

xtnbreg beer lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, fe

outreg2 using "brewery_alternative_xtnbreg_0307.tex", alpha(0.001, 0.01, 0.05) append


*** poisson with robust standard 
xtpoisson brewery lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, fe vce(robust)

outreg2 using "brewery_alternative_xtpoisson_0307.tex", alpha(0.001, 0.01, 0.05) replace

xtpoisson style lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, fe vce(robust)

outreg2 using "brewery_alternative_xtpoisson_0307.tex", alpha(0.001, 0.01, 0.05) append

xtpoisson beer lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, fe vce(robust)

outreg2 using "brewery_alternative_xtpoisson_0307.tex", alpha(0.001, 0.01, 0.05) append

**** PPML without robust standard errors
ppmlhdfe brewery lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, absorb(zipcode year)

outreg2 using "brewery_alternative_ppml_0307.tex", alpha(0.001, 0.01, 0.05) replace


ppmlhdfe style lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, absorb(zipcode year)

outreg2 using "brewery_alternative_ppml_0307.tex", alpha(0.001, 0.01, 0.05) append

ppmlhdfe beer lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, absorb(zipcode year)

outreg2 using "brewery_alternative_ppml_0307.tex", alpha(0.001, 0.01, 0.05) append

* style per brewery and beer per brewery
ppmlhdfe per_style lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, absorb(zipcode state year) vce(cluster zipcode)
outreg2 using "per_brewery_ppml_0307.tex", alpha(0.001, 0.01, 0.05) replace


ppmlhdfe per_beer lagged_super lagged_drink pop popdens ln_income white perbach percentage25 percentage35 percentage45 lagged_homebrew lagged_growler lagged_dtc lagged_self lagged_sampling lagged_sunday, absorb(zipcode state year) vce(cluster zipcode)
outreg2 using "per_brewery_ppml_0307.tex", alpha(0.001, 0.01, 0.05) append

